package org.jeecg.common.util;

import java.util.Base64;

public class Base64Utils {

	public static String decode(String encodedText) {
		Base64.Decoder decoder = Base64.getDecoder();
		try {
			return new String(decoder.decode(encodedText), "UTF-8");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}

	public static String encode(String text) {
		Base64.Encoder encoder = Base64.getEncoder();
		try {
			final byte[] textByte = text.getBytes("UTF-8");
			return encoder.encodeToString(textByte);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}

}
